package com.ap.core.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.ap.core.dao.AbstractReadOnlyAPCoreBaseJpaDao;
import com.ap.core.dao.DistributorEndPointUrlDao;
import com.ap.core.domain.DistributorEndPointUrl;

/**
 * User: Rohit.Dixit
 * Jpa Implementation class for {@link com.ap.core.dao.DistributorDao}
 */
public class JpaDistributorEndPointUrlDao extends AbstractReadOnlyAPCoreBaseJpaDao<DistributorEndPointUrl, Long> implements DistributorEndPointUrlDao{

    @Override
    public DistributorEndPointUrl findById(Long primaryKey) {
        return findById(DistributorEndPointUrl.class, primaryKey);
    }

	@Override
	public List<DistributorEndPointUrl> findByDistributorId(Long distributorId) {
        Criteria criteria = getSession().createCriteria(DistributorEndPointUrl.class);
        criteria.add(Restrictions.eq("distributorId", distributorId));
        criteria.addOrder(Order.desc("id"));
        return (List<DistributorEndPointUrl>)criteria.list();
	}
}
